package com.lb.action;

import java.util.List;

import javax.servlet.ServletRequest;

import org.apache.struts2.ServletActionContext;


import com.lb.bean.User;
import com.lb.service.AdminService;

import com.opensymphony.xwork2.ActionSupport;

public class DeleteUserAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
  private User user;
  private AdminService service;
  private List<User> allUser;
  
	public List<User> getAllUser() {
	return allUser;
}

public void setAllUser(List<User> allUser) {
	this.allUser = allUser;
}

	public User getUser() {
	return user;
}

public void setUser(User user) {
	this.user = user;
}

public AdminService getService() {
	return service;
}

public void setService(AdminService service) {
	this.service = service;
}

	public String execute() throws Exception {
		this.clearActionErrors();

		ServletRequest request = ServletActionContext.getRequest();
		int userId = Integer.parseInt(request.getParameter("userId"));
		
		
		user=this.service.findUserByuserId(userId);
        
       
		this.service.delete(user);
	   allUser=this.service.findAllUser();
		return SUCCESS;

	}
}
